package com.t3.display
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.geom.ColorTransform;
	import flash.geom.Matrix;
	import flash.geom.Rectangle;
	import flash.geom.Point;
	
	public class Mask
	{
		public static function inverseMask( bounds:Rectangle, dob:DisplayObject ):Sprite
		{
		    var bmpd:BitmapData = new BitmapData( bounds.width, bounds.height, true,0xFFFFFFFF);
		    var invert:ColorTransform = new ColorTransform(0,0,0,1);
		    var matrix:Matrix = new Matrix();
		    
		    matrix.translate( 0, 0 );
		    bmpd.draw( dob, matrix, invert );
		    bmpd.threshold( bmpd,new Rectangle( 0, 0, bounds.width, bounds.height ), new Point(0,0),"<",0xFFFFFFFF,0x00FF0000);
		    
		    var bmp:Bitmap = new Bitmap( bmpd );
		    var maskMC:Sprite = new Sprite();
		    
		    maskMC.addChild( bmp );
		    maskMC.cacheAsBitmap = true;
		    
		    return maskMC;
		}
	}
}